/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package creditcardapp.view;

import framework.model.Constant;
import framework.view.AddAccountDialog;
import java.util.HashMap;
import javax.swing.ButtonGroup;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;

/**
 *
 * @author ThanhNguyen
 */
public class AddCreditCardDialog extends AddAccountDialog {

    @Override
    public HashMap<String, String> getFields() {
        HashMap<String, String> fields = super.getFields();
        fields.put(Constant.CC_NUMBER, JTextField_CCNUMBER.getText());
        fields.put(Constant.CC_EXPIRED_DATE, JTextField_EXPIRED_DATE.getText());
        fields.put(Constant.CC_ACCOUNT_TYPE, JRadioButton_Gold.isSelected() ? Constant.CC_TYPE_GOLD
                : (JRadioButton_Silver.isSelected() ? Constant.CC_TYPE_SILVER : Constant.CC_TYPE_BRONZE));
        return fields;
    }
    private JLabel JLabel8;
    private JLabel JLabel9;
    private JTextField JTextField_CCNUMBER;
    private JTextField JTextField_EXPIRED_DATE;
    private JRadioButton JRadioButton_Gold;
    private JRadioButton JRadioButton_Silver;
    private JRadioButton JRadioButton_Bronze;

    @Override
    public void initDialog() {
        setTitle("Add CreditCard Account");
        setModal(true);
        setLayout(null);
        setResizable(false);
    }

    @Override
    public void initAccountTypeControls() {
        int y = 20;
        ButtonGroup radioBtnGroup = new javax.swing.ButtonGroup();
        JRadioButton_Gold = new JRadioButton();
        JRadioButton_Gold.setText("Gold");
        JRadioButton_Gold.setBounds(36 + y, 0, 100, 24);
        add(JRadioButton_Gold);
        radioBtnGroup.add(JRadioButton_Gold);
        JRadioButton_Silver = new JRadioButton();
        JRadioButton_Gold.setSelected(true);
        JRadioButton_Silver.setText("Silver");
        JRadioButton_Silver.setBounds(36 + y, 24, 100, 24);
        add(JRadioButton_Silver);
        radioBtnGroup.add(JRadioButton_Silver);
        JRadioButton_Bronze = new JRadioButton();
        JRadioButton_Bronze.setText("Bronze");
        JRadioButton_Bronze.setBounds(36 + y, 48, 100, 24);
        add(JRadioButton_Bronze);
        radioBtnGroup.add(JRadioButton_Bronze);
    }

    @Override
    public void initAccountControls() {
        JLabel8 = new JLabel();
        JLabel9 = new JLabel();
        JTextField_CCNUMBER = new JTextField();
        JTextField_EXPIRED_DATE = new JTextField();

        int x = 10;
        int y = 5;
        setSize(300, 380 - x);
        JLabel8.setText("CC number");
        getContentPane().add(JLabel8);
        JLabel8.setForeground(java.awt.Color.black);
        JLabel8.setBounds(20 + y, 228 - x, 68, 24);
        JLabel9.setText("Exp. Date");
        getContentPane().add(JLabel9);
        JLabel9.setForeground(java.awt.Color.black);
        JLabel9.setBounds(20 + y, 253 - x, 68, 24);
        getContentPane().add(JTextField_CCNUMBER);
        JTextField_CCNUMBER.setBounds(100 + y, 228 - x, 156, 20);
        getContentPane().add(JTextField_EXPIRED_DATE);
        JTextField_EXPIRED_DATE.setBounds(100 + y, 253 - x, 156, 20);
    }
}
